<?php
declare (strict_types = 1);

namespace app\middleware;

use Firebase\JWT\JWT;
use Firebase\JWT\Key;

class servers
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        $key='zbc';
        $jwt=$request->post('token');

        $decoded = JWT::decode($jwt, new Key($key, 'HS256'));

        if(empty($decoded)){
            return json([
                'status'=>300
            ]);
        }

        return $next($request);
    }
}
